/*
 * Filename:    WorkFlowServiceImpl.java
 * Copyright:   2014 中国平安保险（集团）股份有限公司 版权所有
 * Company:     平安科技养老险及健康险系统开发部
 * Create at:   2014年10月29日
 */
package com.paic.mhis.hcpms.warning.biz.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.paic.mhis.common.util.BusinessServiceUtil;
import com.paic.mhis.hcpms.warning.biz.service.SelfFeedbackService;
import com.paic.mhis.hcpms.warning.dto.PaginationQueryDTO;
import com.paic.mhis.hcpms.warning.dto.WarningGtasksDTO;
import com.paic.mhis.hcpms.warning.intergration.dao.SelfFeedbackDao;
import com.paic.mhis.hcpms.warning.util.WarnConstants;
import com.paic.pafa.app.biz.service.BusinessServiceException;

@Component("selfFeedbackService")
public class SelfFeedbackServiceImpl implements SelfFeedbackService {
	@Autowired
	private SelfFeedbackDao selfFeedbackDao;

	/**
	 * 获取反馈节点信息
	 */
	@Override
	public Map<String, Object> getfeedbackstatus() throws BusinessServiceException {
		// TODO Auto-generated method stub
		Map<String, Object> result = new HashMap<String, Object>();
		try {
			result.put(WarnConstants.SUCCESS_RESULT_KEY, selfFeedbackDao.getFeedbackStatus());
			result.put(WarnConstants.STATE_KEY, WarnConstants.SUCCESS_STATE_VALUE);
			result.put(WarnConstants.MSG_KEY, WarnConstants.SELECT_SUCCESS);
		} catch (Exception e) {
			BusinessServiceUtil.processException(e);
		}
		return result;
	}

	/**
	 * 获取反馈处理方式信息
	 */
	@Override
	public Map<String, Object> getfeedbackprocess() throws BusinessServiceException {
		// TODO Auto-generated method stub
		Map<String, Object> result = new HashMap<String, Object>();
		try {
			result.put(WarnConstants.SUCCESS_RESULT_KEY, selfFeedbackDao.getFeedbackProcess());
			result.put(WarnConstants.STATE_KEY, WarnConstants.SUCCESS_STATE_VALUE);
			result.put(WarnConstants.MSG_KEY, WarnConstants.SELECT_SUCCESS);
		} catch (Exception e) {
			BusinessServiceUtil.processException(e);
		}
		return result;
	}

	/**
	 * 获取待办任务
	 * 
	 * @throws BusinessServiceException
	 */
	@Override
	public Map<String, Object> getGTasks(PaginationQueryDTO taskCondition) throws BusinessServiceException {
		// TODO Auto-generated method stub
		Map<String, Object> result = new HashMap<String, Object>();
		List<WarningGtasksDTO> taskList = new ArrayList<WarningGtasksDTO>();
		try {
			int count = selfFeedbackDao.getGtasksCount(taskCondition.getParam());
			if (count > 0) {
				taskList = selfFeedbackDao.getGtasks(taskCondition);
			}
			result.put(WarnConstants.SUCCESS_RESULT_KEY, taskList);
			result.put(WarnConstants.TOTAL, count);
		} catch (Exception e) {
			BusinessServiceUtil.processException(e);
		}
		return result;
	}
}
